import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Admin
 * Date: 2022-06-08
 * Time: 16:22
 */
public class MyArrayList<E>  implements List<E> {

    public Object[] elem;
    public int UsedSize;

    public MyArrayList() {
        this.elem = new Object[10];
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        MyArrayList<?> that = (MyArrayList<?>) o;
        return Arrays.equals(elem, that.elem);
    }

    @Override
    public String toString() {
        return "MyArrayList" +
                "elem=" + Arrays.toString(elem) ;
    }

    @Override
    public int size() {
        return UsedSize;
    }

    @Override
    public boolean isEmpty() {
        return UsedSize == 0;
    }

    @Override
    public boolean contains(Object o) {
        if(isEmpty()) return false;

        for (int i = 0; i < UsedSize; i++) {
            if(o.equals(elem[i])) {
                return true;
            }
        }
        return false;
    }

    @Override
    public Iterator<E> iterator() {
        return null;
    }

    @Override
    public Object[] toArray() {
        return new Object[0];
    }

    @Override
    public <T> T[] toArray(T[] a) {
        return null;
    }

    public boolean isFull() {
        return UsedSize == elem.length;
    }

    @Override
    public boolean add(Object o) {
       if(isFull()){
           this.elem = Arrays.copyOf(elem,elem.length*2);
       }

       elem[UsedSize] = o;
       UsedSize++;
       return true;
    }

    @Override
    public boolean remove(Object o) {
        if(isEmpty()) return false;

        int i = 0;
        for (; i <UsedSize; i++) {
            if(o.equals(elem[i])) {
                for (int j = i; j < UsedSize; j++) {
                    elem[j] = elem[j+1];
                }
                i--;
            }
        }
        return true;
    }

    @Override
    public boolean containsAll(Collection<?> c) {
        return false;
    }

    @Override
    public boolean removeAll(Collection<?> c) {
        return false;
    }

    @Override
    public boolean retainAll(Collection<?> c) {
        return false;
    }

    @Override
    public boolean addAll(Collection c) {
        if(isFull()) {
            this.elem = Arrays.copyOf(elem,elem.length*2);
        }

        for (int i = UsedSize - 1; i >0 ; i--) {
            elem[i+1] = elem[i];
        }

        elem[0] = c;
        return true;
    }

    @Override
    public boolean addAll(int index, Collection c) {
        return false;
    }

    @Override
    public void clear() {
        int size = UsedSize;
        for (int i = 0; i < size; i++) {
            elem[i] = null;
            UsedSize--;
        }
    }

    @Override
    public E get(int index) {
      return (E)elem[index];
    }

    @Override
    public E set(int index, E element) {
        return null;
    }

    @Override
    public void add(int index, E element) {

    }

    @Override
    public E remove(int index) {
        return null;
    }

    @Override
    public int indexOf(Object o) {
        return 0;
    }

    @Override
    public int lastIndexOf(Object o) {
        return 0;
    }

    @Override
    public ListIterator<E> listIterator() {
        return null;
    }

    @Override
    public ListIterator<E> listIterator(int index) {
        return null;
    }

    @Override
    public List<E> subList(int fromIndex, int toIndex) {
        return null;
    }


}
    class RecentCounter {
        Queue<Integer> queue;

public RecentCounter() {
        queue = new LinkedList<>();
        }

public int ping(int t) {
        queue.offer(t);

        while(queue.peek() < t - 3000) {
        queue.poll();
        }

        return queue.size();
        }
}